package 数据结构;

import java.util.Random;

//经典洗牌算法
class Solution {
    int[] nums;
    public Solution(int[] nums) {
      this.nums = nums;
    }

    public int[] reset() {
      return nums;
    }

    public int[] shuffle() {
        int[] clone = nums.clone();
        int n = nums.length;
        Random random = new Random();
        for (int i = 0; i < n; i++) {
            int j = i+random.nextInt(n-i);
            int tem = clone[i];
            clone[i] = clone[j];
            clone[j] =tem;
        }
        return clone;
    }
}
